package com.example.springboottestgit.service.instruction.stage1;

import com.example.springboottestgit.bean.InstructData;
import com.example.springboottestgit.common.RunNum;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @description:投标有效期
 * @author: ZZZ
 */

@Service
public class TbExpireService {
    static int m = 1;
    static int n = 20;


    public List<InstructData> getInstructData() {
        Random random = new Random();
        List<InstructData> list = new ArrayList<>();
        for (int i = 1; i <= RunNum.a; i++) {
            list.add(mul(i % 3 == 0));
        }
        return list;
    }

    //投标有效期指令
    public InstructData mul(Boolean b) {
        Random random = new Random();
        //Boolean b = random.nextBoolean();
        int x = 0;
        if (b == true) {
            if (m > 20) {
                m = 1;
            }
            x = m++;
        } else {
            if (n > 222) {
                n = 20;
            }
            x = n++;


        }

//        int x = random.nextInt(20) + 1;
//        if (b == true) {
//            x = random.nextInt(30) + 20;
//        }
        String sign = x >= 20 ? "符合" : "不符合";
        String c = x >= 20 ? "大于等于" : "小于";


        String instruction = "投标有效期为投标截止时间起x个日历日是否符合法律法规";
        String input = "";
        String output = "#。根据《中华人民共和国招标投标法》第二十四条规定，自招标文件开始发出之日起至投标人提交投标文件截止之日止，最短不得少于20日，因此案例中投标有效期为投标截止时间起x个日历日#法律法规。";

        instruction = instruction.replace("x", x + "");
        output = output.replace("x", x + "").replace("#", sign + "").replace("c", c + "");

        InstructData instructData = new InstructData();
        instructData.setInstruction(instruction);
        instructData.setInput("");
        instructData.setOutput(output);
        return instructData;
    }
}
